@extends('admin.layouts.app')

@section('right-content')
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>编辑每日任务</legend>
    </fieldset>

    <form class="layui-form" action="" style="margin-right: 60%">

        <div class="layui-form-item">
            <label class="layui-form-label">类别</label>
            <div class="layui-input-block">
                <select name="condition_kind" >
                    @foreach ($type as $value)
                    <option value="{{ $value }}" @if ($daliyMission->condition_kind == $value) selected="" @endif>{{ $value }}</option>
                    @endforeach
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">图片</label>
            <div class="layui-input-block">
                <select name="icon" >
                    @foreach ($icon as $value)
                    <option value="{{ $value }}" @if ($daliyMission->icon == $value) selected="" @endif>{{ $value }}</option>
                    @endforeach
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" value="{{ $daliyMission->name }}" lay-verify="required" autocomplete="off" placeholder="请输入名称" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">条件描述</label>
            <div class="layui-input-block">
                <input type="text" name="description" value="{{ $daliyMission->description }}" lay-verify="required" autocomplete="off" placeholder="请输入条件描述" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">目标值</label>
            <div class="layui-input-inline">
                <input type="text" name="dest_value" value="{{ $daliyMission->dest_value }}" lay-verify="required|number" placeholder="请输入目标值" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">筹码奖励</label>
            <div class="layui-input-inline">
                <input type="text" name="prize_jeton" value="{{ $daliyMission->prize_jeton }}" lay-verify="required|number" placeholder="请输入筹码奖励" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">积分奖励</label>
            <div class="layui-input-inline">
                <input type="text" name="prize_gift_score" value="{{ $daliyMission->prize_gift_score }}" lay-verify="number" placeholder="请输入奖励积分" autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" name="listorder" value="{{ $daliyMission->listorder }}" lay-verify="" placeholder="" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">全平台广播</label>
            <div class="layui-input-block">
                <input type="radio" name="broadcast" value="1" title="是" @if($daliyMission->broadcast == 1) checked="" @endif >
                <input type="radio" name="broadcast" value="0" title="否" @if($daliyMission->broadcast == 0) checked="" @endif>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">触发分享</label>
            <div class="layui-input-block">
                <input type="radio" name="triggle_share" value="1" title="是" @if($daliyMission->triggle_share == 1) checked="" @endif>
                <input type="radio" name="triggle_share" value="0" title="否" @if($daliyMission->triggle_share == 0) checked="" @endif>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                <input type="radio" name="status" value="1" title="上线" @if($daliyMission->status == 1) checked="" @endif>
                <input type="radio" name="status" value="0" title="下线" @if($daliyMission->status == 0) checked="" @endif>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="sub" data-url="{{ route('daliyMissions.update', ['id' => $daliyMission->id]) }}">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
@endsection

@section('my-js')
<script type="text/javascript">
   layui.use('form', function(){
       var form = layui.form;

      form.on('submit(sub)', function(data){
        var url = $(this).attr('data-url');
        commonAjaxSubmit(url, 'PUT');

      })
    });
</script>
@endsection